/**
 * Created by PC on 2018/12/11.
 */
// jQuery.validator.addMethod("verify_num", function (value, element) {
//     var regExp = new RegExp(/^0.\d+/g);
//     if (regExp.test(value)) {
//         return true
//     }
// }, "verify_num");

jQuery.validator.addMethod("verify_num", function (value, element) {
    if (parseFloat(value)  <= 0.2){
        return true
    }
}, "verify_num");



$().ready(function () {
// 在键盘按下并释放及提交后验证提交表单
    // 登录和产品添加
    $("#my_form").validate({
        rules: {
            reserved_b: {
                required: true,
                maxlength: 6,
                number: true,
                verify_num:true
            },
            level1: {
                required: true,
                maxlength: 6,
                number: true
            },
            level2: {
                required: true,
                maxlength: 6,
                number: true
            },
            level3: {
                required: true,
                maxlength: 6,
                number: true
            }
        },
        messages: {
            reserved_b: {
                required: "请填写佣金比例",
                maxlength: "最长不超过4个字符",
                number: "只能输入有效数字",
                verify_num:"预留佣金比例不得超过0.2"
            },
            level1: {
                required: "请填写佣金比例",
                maxlength: "最长不超过4个字符",
                number: "只能输入有效数字"
            },
            level2: {
                required: "请填写佣金比例",
                maxlength: "最长不超过4个字符",
                number: "只能输入有效数字"
            },
            level3: {
                required: "请填写佣金比例",
                maxlength: "最长不超过4个字符",
                number: "只能输入有效数字"
            }
        }
    })
});